<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<logic:empty name="usuario">
	<logic:forward name="login" />
</logic:empty>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">		
		
		<script type="text/javascript">
			function onClickCorregir(hora, periodo, id_tarificador) {
				$("#estado").load("/cargando.htm");
				var mes = $("#mes").val();
				$("#estado").load("/ExplotacionAction.do?metodo=CorregirMedida&hora=" + hora + "&id_tarificador=" + id_tarificador + "&periodo=" + periodo + "&mes=" + mes,null,function (responseText, textStatus , XMLHttpRequest){});				
			}
		</script>
	</head>
	
	<body>
		<div class="block" style="width: 500px; float: left; margin-left: 30px; cursor: default;">
		  	<h3 class="title"><span>Estado Lecturas de <bean:write name="nombre_tarificador" /></span></h3>
			<div class="block-div"></div><div class="block-div-arrow"></div>
			<input type="hidden" id="mes" value="<bean:write name='periodo'/>"/>
			<ul style="margin-left: 10px; overflow: auto; height: 360px; width: 680px;">
				<li>Totales TM1 y TM2 :<br>
					<div style="width: 15%; text-align: center; float: left;">Act. Imp.</div>
					<div style="width: 15%; text-align: center; float: left;">Act. Exp.</div>
					<div style="width: 15%; text-align: center; float: left;">Ract. Q1</div>
					<div style="width: 15%; text-align: center; float: left;">Ract. Q2</div>
					<div style="width: 15%; text-align: center; float: left;">Ract. Q3</div>
					<div style="width: 15%; text-align: center; float: left;">Ract. Q4</div>	
					<b>											
						<div style="width: 15%; text-align: center; float: left;"><bean:write name="total_tm1" property="activa_importada"  format="#,###.##"/></div>
						<div style="width: 15%; text-align: center; float: left;"><bean:write name="total_tm1" property="activa_exportada"  format="#,###.##"/></div>
						<div style="width: 15%; text-align: center; float: left;"><bean:write name="total_tm1" property="reactiva_q1"  format="#,###.##"/></div>
						<div style="width: 15%; text-align: center; float: left;"><bean:write name="total_tm1" property="reactiva_q2"  format="#,###.##"/></div>
						<div style="width: 15%; text-align: center; float: left;"><bean:write name="total_tm1" property="reactiva_q3"  format="#,###.##"/></div>
						<div style="width: 15%; text-align: center; float: left;"><bean:write name="total_tm1" property="reactiva_q4"  format="#,###.##"/></div>
						<logic:equal value="1" name="total_tm2" property="s1">
							<div style="width: 15%; text-align: center; float: left; color: red;"><bean:write name="total_tm2" property="activa_importada"  format="#,###.##"/></div>
						</logic:equal>
						<logic:notEqual value="1" name="total_tm2" property="s1">
							<div style="width: 15%; text-align: center; float: left;"><bean:write name="total_tm2" property="activa_importada"  format="#,###.##"/></div>
						</logic:notEqual>		
						<logic:equal value="1" name="total_tm2" property="s2">
							<div style="width: 15%; text-align: center; float: left; color: red;"><bean:write name="total_tm2" property="activa_exportada"  format="#,###.##"/></div>
						</logic:equal>
						<logic:notEqual value="1" name="total_tm2" property="s2">
							<div style="width: 15%; text-align: center; float: left;"><bean:write name="total_tm2" property="activa_exportada"  format="#,###.##"/></div>
						</logic:notEqual>		
						<logic:equal value="1" name="total_tm2" property="s3">
							<div style="width: 15%; text-align: center; float: left; color: red;"><bean:write name="total_tm2" property="reactiva_q1"  format="#,###.##"/></div>
						</logic:equal>
						<logic:notEqual value="1" name="total_tm2" property="s3">
							<div style="width: 15%; text-align: center; float: left;"><bean:write name="total_tm2" property="reactiva_q1"  format="#,###.##"/></div>
						</logic:notEqual>		
						<logic:equal value="1" name="total_tm2" property="s4">
							<div style="width: 15%; text-align: center; float: left; color: red;"><bean:write name="total_tm2" property="reactiva_q2"  format="#,###.##"/></div>
						</logic:equal>
						<logic:notEqual value="1" name="total_tm2" property="s4">
							<div style="width: 15%; text-align: center; float: left;"><bean:write name="total_tm2" property="reactiva_q2"  format="#,###.##"/></div>
						</logic:notEqual>									
						<logic:equal value="1" name="total_tm2" property="s5">
							<div style="width: 15%; text-align: center; float: left; color: red;"><bean:write name="total_tm2" property="reactiva_q3"  format="#,###.##"/></div>
						</logic:equal>
						<logic:notEqual value="1" name="total_tm2" property="s5">
							<div style="width: 15%; text-align: center; float: left;"><bean:write name="total_tm2" property="reactiva_q3"  format="#,###.##"/></div>
						</logic:notEqual>		
						<logic:equal value="1" name="total_tm2" property="s6">
							<div style="width: 15%; text-align: center; float: left; color: red;"><bean:write name="total_tm2" property="reactiva_q4"  format="#,###.##"/></div>
						</logic:equal>
						<logic:notEqual value="1" name="total_tm2" property="s6">
							<div style="width: 15%; text-align: center; float: left;"><bean:write name="total_tm2" property="reactiva_q4"  format="#,###.##"/></div>
						</logic:notEqual>								
					</b>
				</li>
				<br><br><br><br>
										
							
				<li>Número Horas TM1 <span style="color: red;">[Registradas]</span> (Mes:<bean:write name="num_horas_mes_tm1" format="#"/>) : <b>&nbsp;&nbsp;<bean:write name="num_horas_tm1" format="#"/><span style="color: red; text-align: right;"> [<bean:write name="num_lecturas_tm1" format="#"/>]</span></b></li> 
				<li>Número Horas TM2 <span style="color: red;">[Registradas]</span> (Mes:<bean:write name="num_horas_mes_tm2" format="#"/>) : <b><bean:write name="num_horas_tm2" format="#"/><span style="color: red;"> [<bean:write name="num_lecturas_tm2" format="#"/>]</span></b></li>
				<br />	
								
				<logic:notEmpty name="duplicados_tm1">
					<li>Lecturas TM1 Duplicadas : </li>
					<div style="clear: both; margin-left: 5px;">
						<logic:iterate id="duplicada" name="duplicados_tm1">		
							<span style="color: red;" onmouseover="this.style.fontWeight = 'bold'; this.style.fontSize = '13px';" onmouseout="this.style.fontWeight = 'normal'; this.style.fontSize = '13px';">
								[<bean:write name="duplicada" property="fecha"  format="dd/MM/yyyy HH:mm"/>]		
							</span>						
						</logic:iterate>
					</div>
				</logic:notEmpty>
				<logic:empty name="duplicados_tm1">
					<li>Lecturas TM1 Duplicadas : <span style="color: red;">No Hay</span></li>
				</logic:empty>
				<logic:notEmpty name="duplicados_tm2">
					<li>Lecturas TM2 Duplicadas : </li>
					<div style="clear: both; margin-left: 5px;">
						<logic:iterate id="duplicada" name="duplicados_tm2">		
							<span style="color: red;" onmouseover="this.style.fontWeight = 'bold'; this.style.fontSize = '13px';" onmouseout="this.style.fontWeight = 'normal'; this.style.fontSize = '13px';">
								[<bean:write name="duplicada" property="fecha"  format="dd/MM/yyyy HH:mm"/>]		
							</span>						
						</logic:iterate>
					</div>
				</logic:notEmpty>
				<logic:empty name="duplicados_tm2">
					<li>Lecturas TM2 Duplicadas : <span style="color: red;">No Hay</span></li>
				</logic:empty>				
				<br />
				
				<logic:notEmpty name="huecos_tm1">
					<li>Huecos Lecturas TM1 : </li>
					<div style="clear: both; margin-left: 20px;">
						<logic:iterate id="hueco" name="huecos_tm1">		
							<span style="color: red;" onmouseover="this.style.fontWeight = 'bold'; this.style.fontSize = '14px';" onmouseout="this.style.fontWeight = 'normal'; this.style.fontSize = '13px';">
								<bean:write name="hueco"/><br>		
							</span>						
						</logic:iterate>
					</div>
				</logic:notEmpty>
				<logic:empty name="huecos_tm1">
					<li>Huecos Lecturas TM1 : <span style="color: red;">No Hay</span></li>
				</logic:empty>
				<logic:notEmpty name="huecos_tm2">
					<li>Huecos Lecturas TM2 : </li>
					<div style="clear: both; margin-left: 20px;">
						<logic:iterate id="hueco" name="huecos_tm2">		
							<span style="color: red;" onmouseover="this.style.fontWeight = 'bold'; this.style.fontSize = '14px';" onmouseout="this.style.fontWeight = 'normal'; this.style.fontSize = '13px';">
								<bean:write name="hueco"/><br>	
							</span>						
						</logic:iterate>
					</div>
				</logic:notEmpty>
				<logic:empty name="huecos_tm2">
					<li>Huecos Lecturas TM2 : <span style="color: red;">No Hay</span></li>
				</logic:empty>				
				<br />			


				<logic:notEmpty name="diferentes_tm1">
					<li>Diferencias Lecturas TM1 y TM2 : </li>
					<div style="clear: both; margin-left: 5px;">
						<div style="width: 20%; text-align: center; float: left;">Fecha</div>
						<div style="width: 13%; text-align: center; float: left;">Act. Imp.</div>
						<div style="width: 13%; text-align: center; float: left;">Act. Exp.</div>
						<div style="width: 13%; text-align: center; float: left;">Ract. Q1</div>
						<div style="width: 13%; text-align: center; float: left;">Ract. Q2</div>
						<div style="width: 13%; text-align: center; float: left;">Ract. Q3</div>
						<div style="width: 13%; text-align: center; float: left;">Ract. Q4</div>			
						<br>			
						<%int contador = 0;%>
						<logic:iterate id="diferencia" name="diferentes_tm1">		
							<span style="font-weight: bold;">
								<div style="width: 20%; text-align: center; float: left;"><bean:write name="diferencia" property="fecha"  format="dd/MM/yyyy HH:mm"/></div>
								<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia" property="activa_importada"  format="#,###.##"/></div>
								<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia" property="activa_exportada"  format="#,###.##"/></div>
								<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia" property="reactiva_q1"  format="#,###.##"/></div>
								<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia" property="reactiva_q2"  format="#,###.##"/></div>
								<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia" property="reactiva_q3"  format="#,###.##"/></div>
								<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia" property="reactiva_q4"  format="#,###.##"/></div>											
							</span>	
							<logic:iterate id="diferencia2" name="diferentes_tm2" offset="<%=Integer.toString(contador)%>" length="4">
								<logic:equal name="diferencia2" property="s1" value="0">
									<span style="color: red;">
										<div style="width: 20%; text-align: center; float: left;"><bean:write name="diferencia2" property="fecha"  format="dd/MM/yyyy HH:mm"/></div>
										<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia2" property="activa_importada"  format="#,###.##"/></div>
										<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia2" property="activa_exportada"  format="#,###.##"/></div>
										<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia2" property="reactiva_q1"  format="#,###.##"/></div>
										<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia2" property="reactiva_q2"  format="#,###.##"/></div>
										<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia2" property="reactiva_q3"  format="#,###.##"/></div>
										<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia2" property="reactiva_q4"  format="#,###.##"/></div>											
									</span>						
								</logic:equal>
								<logic:equal name="diferencia2" property="s1" value="1">
									<a href="javascript: onClickCorregir('<bean:write name='diferencia2' property='hora' format='#'/>','<bean:write name='diferencia2' property='periodo' format="yyyy-MM-dd"/>','<bean:write name='diferencia' property='tarificador.id_tarificador' format='#'/>');">
										<div style="width: 20%; text-align: center; float: left;"><bean:write name="diferencia2" property="fecha"  format="dd/MM/yyyy HH:mm"/></div>
										<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia2" property="activa_importada"  format="#,###.##"/></div>
										<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia2" property="activa_exportada"  format="#,###.##"/></div>
										<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia2" property="reactiva_q1"  format="#,###.##"/></div>
										<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia2" property="reactiva_q2"  format="#,###.##"/></div>
										<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia2" property="reactiva_q3"  format="#,###.##"/></div>
										<div style="width: 13%; text-align: center; float: left;"><bean:write name="diferencia2" property="reactiva_q4"  format="#,###.##"/></div>											
									</a>						
								</logic:equal>
							</logic:iterate>
							<%contador += 4;%>			
						</logic:iterate>
					</div>
				</logic:notEmpty>
				<logic:empty name="diferentes_tm1">
					<li>Diferencias Lecturas TM1 y TM2 : <span style="color: red;">No Hay</span></li>
				</logic:empty>			
			</ul>
		 </div>	  			
	</body>
</html>
